package file_operation;

import java.io.File;
import java.io.FileFilter;

/**
 * 递归打印多级目录
 * */
public class MultilevelDirectoryPrinting {
	public static void printDirectory(File drectory) {
		File[] files = drectory.listFiles();
		for (File file : files) {
			if (file.isFile())
				System.out.println("文件名：" + file.getAbsolutePath());
			else {
				System.out.println("目录：" + file.getAbsolutePath());
				printDirectory(file);
			}
		}
	}
	
	public static void printDirectory(File drectory, FileFilter fileFilter) {
		File[] files = drectory.listFiles(fileFilter);
		for (File file : files) {
			if (file.isFile())
				System.out.println("文件名：" + file.getAbsolutePath());
			else {
				System.out.println("目录：" + file.getAbsolutePath());
				printDirectory(file, fileFilter);
			}
		}
	}
	
	public static void main(String[] args) {
		File drectory = new File("D:\\Projects\\JavaProjects\\Demo_eclipse\\src");
		printDirectory(drectory);
	}
}
